<?php
	$post = $this->get("post");
?>
<form method="post" action="<?php _e(actionUrl($this))?>"  id="task-form" enctype="multipart/form-data">
<input type="hidden" name="ID" value="<?php _e($post['ID'])?>"/>

<div class="x-list-title">
		<table width="100%" border="0" height="100%">
		<tr>
			<td align="left">
				<h2>
                <?php _e($post['title'])?>
				</h2>
			</td>
			<td align="right">	
                <div class="x-list-options">
						<div class="x-options-container">
							<a class="x-button"> Tác vụ khác <span>&#9660;</span></a>
							<div class="x-options">
								<a href="#asset/Index/edit?ID=<?php _e($post['ID']);?>" class="x-options-item">Sửa tài sản</a>
								<a href="#asset/Index/changestatus?ID=<?php _e($post['ID']);?>" class="x-options-item">Chuyển trạng thái</a>
								
								<a class="x-options-item" onclick="load_inframe('<?php _baseUrl();?>/Asset/Index/transfer?ID=<?php _e($_REQUEST["ID"])?>',{title: 'Thông tin bàn giao tài sản',css_content:{},auto_hidden: true })">Bàn giao mới</a> 
								<a onclick="module_delete('<?php _e(BASE_URL)?>/asset/Index/delete?ID=<?php _e($post['ID']);?>')" class="x-options-item">Xóa tài sản</a>
							
							</div>
						</div>
					</div>
			</td>
		</tr>
		</table>	
</div>
<div class="x-info" >
	<table width="100%" cellpadding="7" class="x-info" style="border:1px solid #ccc;">
					<td class="x-info-top" colspan="4" style="border-right:1px solid #ccc;" >
							<span class="tl">Thông tin chung</span>
							<span class="tr">Cập nhật lần cuối lúc <?php _e( show_date(DATETIME_FORMAT,$post['date_updated']) );?> bởi <?php _e(get_user_link( $post['updated_by_id'],$post['updated_by_name'],$post['updated_is_deleted']) );?></a></span>
						</td>
					<tr>
						<td class="x-info-label">Mã tài sản</td>
						<td class="x-info-content" style="color:red" >
							<?php _e($post["code"]);?>
						</td>
						<td class="x-info-label">Tên tài sản</td>
						<td class="x-info-content" style="color:green" >
							<b><?php _e($post["title"]);?></b>
						</td>
					</tr>
					<tr>
						<td class="x-info-label">Loại tài sản</td>
						<td class="x-info-content">
							<a><?php _e($post["asset_type_title"]);?></a>
						</td>
						<td class="x-info-label">Hãng sản xuất</td>
						<td class="x-info-content">
							<?php _e($post["origin"]);?>
						</td>
						
					</tr>
					<tr>
						<td class="x-info-label">Ngày mua</td>
						<td class="x-info-content">
							<?php _e(show_date(DATE_FORMAT,$post["datebuy"]));?>
						</td>
						<td class="x-info-label">Giá</td>
						<td class="x-info-content">
							<? _e(number_format($post['value'],0,",",","))?>
							<span style="color:brown;font-weight:bold;">[ <?php _e($post['mtype'])?> ]</span>
						</td>
					</tr>
					<tr>
						
						<td class="x-info-label">Thời gian bảo hành</td>
						<td class="x-info-content">
							<?php _e(show_date(DATE_FORMAT,$post["time"]));?>
						</td>
						<td class="x-info-label">Mã số bảo hành</td>
						<td class="x-info-content">
							<?php _e($post["codesu"]);?>
						</td>
					</tr>
					<tr>
						<td class="x-info-label">Địa điểm mua</td>
						<td class="x-info-content">
							<?php _e($post["buyat"]);?>
						</td>
						<td class="x-info-label">Tình trạng tài sản</td>
						<td class="x-info-content">
							<?php $post["status"]=='using'?_e('Đang sử dụng'):_e('Không sử dụng')?>
						</td>
					</tr>
					<tr>
						<td class="x-info-label">Model</td>
						<td class="x-info-content">
							<?php _e($post["model"]);?>
						</td>
						<td class="x-info-label">Tài liệu đính kèm</td>
							<td class="x-info-content" colspan="3">
								<?php 
								$file = $this->get('files');
								if(count($file)>0){
								foreach($file as $f){?>
									<?php $a=array();?>
									<?php show_thumb( $f, baseUrl()."/Asset/Index/File?ID={$f['ID']}");?>
								<?php }
									}else{
										_e("<i>Không có file đính kèm.</i>");
									}
								?>
								
							</td>
					</tr>
					<tr>
						<td class="x-info-label">Mô tả</td>
						<td class="x-info-content" colspan="3" >
							<?php _e($post["desc"]);?>
						</td>
					</tr>
	</table>
	<div style="padding:2px"></div>
<?php $transfers = $this->get('transfers');?>
	<table width="100%" class="x-list" cellpadding="0" cellspacing="0">
	<tr>
		<th width="25" align="center">
			TT
		</th>
		<th align="center"  width="70">
			Mã
		</th>
		<th align="center"  width="150">
			Đơn vị sử dụng
		</th>
		<th align="center">
			Người sử dụng
		</th>
		<th align="center" width="120">
			Ngày bàn giao
		</th>
		<th align="center" width="120">
			Người bàn giao
		</th>
		<th align="center" >
			<a class="x-delete"></a>
		</th>
	</tr>	
	<?php if( count($transfers) == 0 ){?>
	<tr>
	<td colspan="7" class="page">
		<div class="x-page">
			Chưa có lần bàn giao nào
		</div>
	</td>
	</tr>
	<?php }else{?>
<?php foreach( $transfers as $k => $a ){?>
	<?php $vars = $this->get('vars');?>
	<tr>
		<td align="center">
			<?php _e($k+1);?>
		</td>
		<td align="center">
			<?php _e($a['code_transfers'])?>
		</td>
		<td align="center">
			<?php _e($a['depart_name'])?>
		</td>
		<td>
			<?php
				$us =array();
				foreach( $a['users'] as $u ){
					$us[] = get_user_link( $u );			
				}
				_e( implode(', ', $us ) );
			?>
		</td>

		<td align="center">
			<span ><?php _e(show_date("H:i:s d/m/Y",$a['date_created']))?></span>
		</td>
		<td width="120" align="center">
			<?php _e($a['created_by_name'])?>
		</td>
		<td width="25" align="center">
			<?php if($a["created_by_id"]==$this->get('user_id')){?>
			<a onclick="module_delete('<?php _baseUrl()?>/asset/Index/deletetranfers?ID=<?php _e($a['ID']);?>&&asset_id=<?php _e($_REQUEST['ID']);?>')" class="x-delete"></a>
			<?php }else{?>
			<a class="x-nodelete"></a>
			<?php } ?>
		</td>
	</tr>
	<?php }}?>
	</table>
	<!-- END LIST-->
</div>
</form>